<!doctype html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="学习笔记,linux," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="前言前段时间自学了Linux系统，vi编辑器常常在学习的过程中有用到。熟练使用vi命令对于我们操作Linux系统有很大的帮助，我在此把我练习过程中用到的vi命令给整理了一下。">
<meta property="og:type" content="article">
<meta property="og:title" content="vi学习笔记">
<meta property="og:url" content="http://jieminblog.tk/2017/03/08/vi学习笔记/index.html">
<meta property="og:site_name" content="jiemin's Blog">
<meta property="og:description" content="前言前段时间自学了Linux系统，vi编辑器常常在学习的过程中有用到。熟练使用vi命令对于我们操作Linux系统有很大的帮助，我在此把我练习过程中用到的vi命令给整理了一下。">
<meta property="og:updated_time" content="2017-03-08T05:34:57.371Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="vi学习笔记">
<meta name="twitter:description" content="前言前段时间自学了Linux系统，vi编辑器常常在学习的过程中有用到。熟练使用vi命令对于我们操作Linux系统有很大的帮助，我在此把我练习过程中用到的vi命令给整理了一下。">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://jieminblog.tk/2017/03/08/vi学习笔记/"/>





  <title> vi学习笔记 | jiemin's Blog </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  














  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">jiemin's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">本来无一物，何处惹尘埃</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://jieminblog.tk/2017/03/08/vi学习笔记/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="我爱的乌托邦">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/uploads/touxiang.jpeg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="jiemin's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                vi学习笔记
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-03-08T11:27:13+08:00">
                2017-03-08
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>前段时间自学了Linux系统，vi编辑器常常在学习的过程中有用到。熟练使用<code>vi</code>命令对于我们操作Linux系统有很大的帮助，我在此把我练习过程中用到的<code>vi</code>命令给整理了一下。</p>
<a id="more"></a>
<h1 id="vi命令"><a href="#vi命令" class="headerlink" title="vi命令"></a>vi命令</h1><h2 id="移动光标类命令"><a href="#移动光标类命令" class="headerlink" title="移动光标类命令"></a>移动光标类命令</h2><table>
<thead>
<tr>
<th style="text-align:center">命令</th>
<th style="text-align:center">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">w或W</td>
<td style="text-align:center">光标右移一个字至字首</td>
</tr>
<tr>
<td style="text-align:center">b或B</td>
<td style="text-align:center">光标左移一个字至字首</td>
</tr>
<tr>
<td style="text-align:center">e或E</td>
<td style="text-align:center">光标右移一个字至字尾</td>
</tr>
<tr>
<td style="text-align:center">)</td>
<td style="text-align:center">光标移至句尾</td>
</tr>
<tr>
<td style="text-align:center">(</td>
<td style="text-align:center">光标移至句首</td>
</tr>
<tr>
<td style="text-align:center">}</td>
<td style="text-align:center">光标移至段落开头</td>
</tr>
<tr>
<td style="text-align:center">{</td>
<td style="text-align:center">光标移至段落结尾</td>
</tr>
<tr>
<td style="text-align:center">nG</td>
<td style="text-align:center">光标移至第n行首</td>
</tr>
<tr>
<td style="text-align:center">n+</td>
<td style="text-align:center">光标下移n行</td>
</tr>
<tr>
<td style="text-align:center">n-</td>
<td style="text-align:center">光标上移n行</td>
</tr>
<tr>
<td style="text-align:center">n$</td>
<td style="text-align:center">光标移至第n行尾</td>
</tr>
<tr>
<td style="text-align:center">H</td>
<td style="text-align:center">光标移至屏幕顶行</td>
</tr>
<tr>
<td style="text-align:center">M</td>
<td style="text-align:center">光标移至屏幕中间行</td>
</tr>
<tr>
<td style="text-align:center">L</td>
<td style="text-align:center">光标移至屏幕最后行</td>
</tr>
<tr>
<td style="text-align:center">0(数字零)</td>
<td style="text-align:center">光标移至当前行行首</td>
</tr>
<tr>
<td style="text-align:center">$</td>
<td style="text-align:center">光标移至当前行尾</td>
</tr>
</tbody>
</table>
<h2 id="屏幕翻滚类命令"><a href="#屏幕翻滚类命令" class="headerlink" title="屏幕翻滚类命令"></a>屏幕翻滚类命令</h2><table>
<thead>
<tr>
<th style="text-align:center">命令</th>
<th style="text-align:center">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">ctrl+u</td>
<td style="text-align:center">向文件首翻半屏</td>
</tr>
<tr>
<td style="text-align:center">ctrl+d</td>
<td style="text-align:center">向文件尾翻半屏</td>
</tr>
<tr>
<td style="text-align:center">ctrl+b</td>
<td style="text-align:center">向文件首翻一屏</td>
</tr>
<tr>
<td style="text-align:center">ctrl+f</td>
<td style="text-align:center">向文件尾翻一屏</td>
</tr>
</tbody>
</table>
<h2 id="插入文本类命令"><a href="#插入文本类命令" class="headerlink" title="插入文本类命令"></a>插入文本类命令</h2><table>
<thead>
<tr>
<th style="text-align:center">命令</th>
<th style="text-align:center">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">i</td>
<td style="text-align:center">在光标前插入</td>
</tr>
<tr>
<td style="text-align:center">I</td>
<td style="text-align:center">在当前行首插入</td>
</tr>
<tr>
<td style="text-align:center">a</td>
<td style="text-align:center">在光标后插入</td>
</tr>
<tr>
<td style="text-align:center">A</td>
<td style="text-align:center">在当前行尾插入</td>
</tr>
<tr>
<td style="text-align:center">o</td>
<td style="text-align:center">在当前行之下新开一行</td>
</tr>
<tr>
<td style="text-align:center">O</td>
<td style="text-align:center">在当前行之上新开一行</td>
</tr>
<tr>
<td style="text-align:center">r</td>
<td style="text-align:center">替换当前字符</td>
</tr>
<tr>
<td style="text-align:center">R</td>
<td style="text-align:center">替换当前字符及其后的字符，直至按ESC键</td>
</tr>
</tbody>
</table>
<h2 id="删除命令"><a href="#删除命令" class="headerlink" title="删除命令"></a>删除命令</h2><table>
<thead>
<tr>
<th style="text-align:center">命令</th>
<th style="text-align:center">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">d0</td>
<td style="text-align:center">删至行首</td>
</tr>
<tr>
<td style="text-align:center">d$</td>
<td style="text-align:center">删至行尾</td>
</tr>
<tr>
<td style="text-align:center">ndd</td>
<td style="text-align:center">删除当前行及其后n-1行</td>
</tr>
<tr>
<td style="text-align:center">x或X</td>
<td style="text-align:center">删除一个字符，x删除光标后的，而X删除光标前的</td>
</tr>
</tbody>
</table>
<h2 id="搜索及替换命令"><a href="#搜索及替换命令" class="headerlink" title="搜索及替换命令"></a>搜索及替换命令</h2><table>
<thead>
<tr>
<th style="text-align:center">命令</th>
<th style="text-align:center">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">/pattern</td>
<td style="text-align:center">从光标开始处向文件尾搜索pattern</td>
</tr>
<tr>
<td style="text-align:center">?pattern</td>
<td style="text-align:center">从光标开始处向文件首搜索pattern</td>
</tr>
<tr>
<td style="text-align:center">n</td>
<td style="text-align:center">在同方向重复上一次搜索命令</td>
</tr>
<tr>
<td style="text-align:center">N</td>
<td style="text-align:center">在反方向上重复一次搜索命令</td>
</tr>
<tr>
<td style="text-align:center">: s/p1/p2/g</td>
<td style="text-align:center">将当前行中所有的p1均用p2代替</td>
</tr>
<tr>
<td style="text-align:center">: g/p1/s//p2/g</td>
<td style="text-align:center">将文件中所有的p1均用p2替换</td>
</tr>
</tbody>
</table>
<h2 id="其他命令"><a href="#其他命令" class="headerlink" title="其他命令"></a>其他命令</h2><table>
<thead>
<tr>
<th style="text-align:center">命令</th>
<th style="text-align:center">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">: q</td>
<td style="text-align:center">退出</td>
</tr>
<tr>
<td style="text-align:center">: q!</td>
<td style="text-align:center">强行退出</td>
</tr>
<tr>
<td style="text-align:center">: wq</td>
<td style="text-align:center">保存退出</td>
</tr>
<tr>
<td style="text-align:center">u</td>
<td style="text-align:center">撤销修改的</td>
</tr>
<tr>
<td style="text-align:center">: set number</td>
<td style="text-align:center">显示行号</td>
</tr>
</tbody>
</table>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>


    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/学习笔记/" rel="tag"># 学习笔记</a>
          
            <a href="/tags/linux/" rel="tag"># linux</a>
          
        </div>
      

      
        
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/03/07/Nginx反向代理小应用/" rel="next" title="Nginx反向代理小应用">
                <i class="fa fa-chevron-left"></i> Nginx反向代理小应用
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/03/08/Eclipse如何修改dynamic-web-module-version/" rel="prev" title="Eclipse如何修改dynamic web module version">
                Eclipse如何修改dynamic web module version <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>

          
          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/uploads/touxiang.jpeg"
               alt="我爱的乌托邦" />
          <p class="site-author-name" itemprop="name">我爱的乌托邦</p>
           
              <p class="site-description motion-element" itemprop="description"></p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">17</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">15</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#前言"><span class="nav-number">1.</span> <span class="nav-text">前言</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#vi命令"><span class="nav-number">2.</span> <span class="nav-text">vi命令</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#移动光标类命令"><span class="nav-number">2.1.</span> <span class="nav-text">移动光标类命令</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#屏幕翻滚类命令"><span class="nav-number">2.2.</span> <span class="nav-text">屏幕翻滚类命令</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#插入文本类命令"><span class="nav-number">2.3.</span> <span class="nav-text">插入文本类命令</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#删除命令"><span class="nav-number">2.4.</span> <span class="nav-text">删除命令</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#搜索及替换命令"><span class="nav-number">2.5.</span> <span class="nav-text">搜索及替换命令</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#其他命令"><span class="nav-number">2.6.</span> <span class="nav-text">其他命令</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">我爱的乌托邦</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    
    
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  




  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.0"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  



  




	





  





  





  



  
  

  

  

  

  


  

</body>
</html>
